package com.hllxd.hism.star.basic.service.controller2;

import com.hllxd.hism.framework.httprpc.service.*;
import com.hllxd.hism.star.basic.service.exception.BusinessException;
import com.hllxd.hism.star.basic.service.service.rock.CostOverviewService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Author wuguangxi
 * @Description
 * @Date 2024/5/7 17:46
 */
@Slf4j
@RestGrpcService
@RestGrpcMapping("/v1/costOverview")
public class CostOverviewController {
    @Autowired
    private CostOverviewService costOverviewService;

    @RestGrpcMapping("/getCostOverview.do")
    public NTSTATUS getCostOverview(PDRIVER_OBJECT params, PRESULT_OBJECT result) {
        log.info("request params: {}, user: {}", params, params.userID);
        try {
            CostOverviewController.Params aa = params.driverObject(CostOverviewController.Params.class);
            result.setData(costOverviewService.findCostOverview(aa.getDt(), aa.getOa()));
            return NTSTATUS.SUCCESS_STATUS();
        } catch (BusinessException e) {
            log.warn("Exception: {}. {}", e, params);
            return NTSTATUS.ERROR_STATUS(e.code, e.msg);
        } catch (Exception e) {
            log.error("Exception: {}. {}", e, params, e);
            return NTSTATUS.ERROR_STATUS("500", e.toString());
        }
    }

    @Data
    public static class Params {
        private String dt;

        private String oa;

    }
}
